package com.jumi.microservice.service.order;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.jumi.microservice.dto.excel.ExportOrderAllResponse;
import com.jumi.microservice.dto.logistics.excel.BatchUpdateRealLogisticsNo;
import com.jumi.microservice.service.logistics.admin.SendService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author by mazhao
 * @Classname SelfWaitSendListener
 * @Description TODO
 * @Date 2020/9/9 13:47
 */
public class SendListener extends AnalysisEventListener<ExportOrderAllResponse> {

    private SendService sendService;

    private Long uid;

    private String name;

    List<ExportOrderAllResponse> list = new ArrayList<>();

    @Override
    public void invoke(ExportOrderAllResponse exportOrderAllResponse, AnalysisContext analysisContext) {
        list.add(exportOrderAllResponse);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        //全部读完业务逻辑
        saveData(list);
    }

    public SendListener(SendService sendService, Long uid, String name) {
        this.sendService = sendService;
        this.name = name;
        this.uid  = uid;
    }

    public void saveData(List<ExportOrderAllResponse> list){
        sendService.partSend(list,uid,name);
    }
}
